import java.util.*;

/**
 * This program finds prime numbers till a number entered by a user
 * @version 0.01 2014-01-10
 * @author Sergii Koziumynskyi
 */

public class PrimeNumbers
{
	public static void main(String[] args)
	{
		// ask user about a value
		Scanner in = new Scanner(System.in);
		System.out.println("Enter a number from 2 to 100,000.");
		String tmp = in.next();

		// check the entered value
	    int n = 0;
		try{
		   n = Integer.parseInt(tmp);
 	    } catch (NumberFormatException nfe) {
 		   System.out.println("Entered value is bigger than 2 billions or not a number.");
 	    };

		if (n < 2 || n > 100000) {
			System.out.println("The number should be in 2 - 100,000 diapason.");

		// if entered value meets the criteria, continue execution
		} else {
			// store all numbers between 2 and the entered value
			ArrayList<Integer> numbers = new ArrayList<Integer>();
			for (int i = 2; i <= n; i++) {
				numbers.add(i);
			}				

			// remove composite numbers
			for (int i = 0; i < numbers.size() - 1; i++) { // -1 because there is no sense in check of the last element
				for (int j = i + 1; j < numbers.size(); j++) {
					if (numbers.get(j) % numbers.get(i) == 0) {
						numbers.remove(j);
						j--; // check current index again because it contains a new value
					}
				}
			}			
			System.out.println(numbers);
		}	
	}
}